package bankaccount;

public class CheckingAccount extends BankAccount {
    private double overdraftLimit;

    public CheckingAccount(String accountNumber, String accountHolder, double balance,double overdraftLimit) {
        super(accountNumber, accountHolder, balance);
        this.overdraftLimit = overdraftLimit;
    }

    @Override
    public String accountType() {
        return "Checking";
    }
    public void withdraw(double money) {
        double currentBalance = getBalance();
        System.out.println("取："+money);
        System.out.println("限额："+overdraftLimit);
        if (money > 0 && money<= getBalance()) {
            if(money<=overdraftLimit){
                setBalance(currentBalance - money);
                System.out.println("余额："+getBalance());
            }else {
                System.out.println("超出限额");
            }
        }else {
            System.out.println("余额不足");
        }
    }
}
